<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // 检测有效数字
    console.log(12, isNaN(12))
    console.log('13', isNaN('13'))
    console.log('覃狄', isNaN('覃狄'))
    console.log(false, isNaN(false))
    console.log('null', isNaN(null))
    console.log('undefined', isNaN(undefined))
    console.log(Number(null));
    console.log(Number(undefined));
    console.log(Number([12]));
    console.log(isNaN([12]));
    console.log(NaN == NaN);

    //数据类型检测
    // typeof -> 只能检测基本数据类型，引用数据类型统一返回 object
    console.log(typeof 1); // number
    console.log(typeof 'qindi'); // string
    console.log(typeof true); // boolean 
    console.log(typeof null); // object 
    console.log(typeof undefined); //undefined
    console.log(typeof {}); //object
    console.log(typeof []); // object 
    console.log(typeof /^/);
    console.log(typeof typeof 1); // string 

    // instanceof 判断构造函数的 prototype 属性是否出现在对象的原型链的任何位置
    {
      function Dog(name, age) {
        this.name = name
        this.age = age
      }
      const myDog = new Dog('覃狄', 18)
      console.log(myDog instanceof Dog);
      console.log(myDog instanceof Object);
      console.log(Dog instanceof Function);
    }
    // Object.prototype.toString.call()
    {
      console.log('-----------');
      Object.prototype.toString.call(null)
      Object.prototype.toString.call('An')
      Object.prototype.toString.call(1)
      Object.prototype.toString.call(Symbol(1))
      Object.prototype.toString.call(undefined)
      Object.prototype.toString.call(function () { })
      Object.prototype.toString.call({ name: 'an' })
    }
  </script>
</body>

</html>